<?php
if(!defined('IN_WOGU')) {
    exit('Access Denied');
}

Loader::loadClass('Model');

class FailedLoginsModel extends Model
{
    protected $_table = 'failedlogins';
    //默认禁止时间为1小时
    const EXPIRE = 3600;
    const TRYNUMS = 5;

    public function getByIp($ip) {
        return $this->getOne(array('ip' => $ip));
    }
    
    public function updateByIp($ip, $nums) {
        $data = array(
            'nums' => $nums,
            'lastvist' => SYS_TIME
        );
        
        return $this->update($data, array('ip' => $ip));
    }
    
    public function insertByIp($ip, $nums) {
        $data = array(
            'ip' => $ip,
            'nums' => $nums,
            'lastvist' => SYS_TIME
        );
        
        return $this->insert($data);
    }
}